package com.nuoniu.sibanyun.service.crm.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nuoniu.sibanyun.common.lang.StringUtils;
import com.nuoniu.sibanyun.entity.crm.CrmForm;
import com.nuoniu.sibanyun.mapper.crm.CrmFormMapper;
import com.nuoniu.sibanyun.service.crm.ICrmFormService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import com.nuoniu.sibanyun.userThread.UserThreadLocal;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 邀约表单 服务实现类
 * </p>
 *
 * @author 白强
 * @since 2021-09-09
 */
@Service
public class CrmFormServiceImpl extends ServiceImpl<CrmFormMapper, CrmForm> implements ICrmFormService {

    @Override
    public Page<CrmForm> pageList(Page page, CrmForm form) {
        QueryWrapper wrapper = new QueryWrapper();
        UserInfo userInfo = UserThreadLocal.get();
        wrapper.eq("company_id", userInfo.getCompanyId());
        if(StringUtils.isNotBlank(form.getFormName())) {
            wrapper.like("form_name", form.getFormName());
        }

        if(StringUtils.isNotBlank(form.getActivityName())) {
            wrapper.like("activity_name", form.getActivityName());
        }

        wrapper.orderByDesc("create_date");
        return page(page, wrapper);
    }
}
